package databse.persistent;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import orm.Actor;
import orm.City;
import repositories.ActorRepository;
import repositories.CityRepository;

public class App 
{
	private static ActorRepository actorRepository;
	
	
    public static void main( String[] args )
    {
    	ApplicationContext appContext = new ClassPathXmlApplicationContext("/beans.xml");
    	actorRepository = (ActorRepository)appContext.getBean("actorRepository");
    	List<Actor> actors = actorRepository.findAll();
    	for(Actor actor:actors){
    		System.out.println("actor : " + actor.getFirstName());
    	}
    	
    	actors = actorRepository.findByFirstName("Mary");
    	for(Actor actor:actors){
    		System.out.println("actor : " + actor.getFirstName());
    	}
    	
    	CityRepository cityRepository = (CityRepository)appContext.getBean("cityRepository");
    	List<City> cities = cityRepository.findAll();
    	for(City city:cities){
    		System.out.println("city : " + city.getCity());
    	}
    	
    }
}
